
//
// 110422 - AH - Created.
//

package org.soekrat.gui.swing.synesthesia;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Frame;
import java.net.URL;

import javax.swing.JDialog;
import javax.swing.JScrollPane;

/**
 * 
 * @author Arne Halvorsen
 *
 */
@SuppressWarnings("serial")
public final class ImageViewDialog extends JDialog 
{
  private final ImagePanel m_panel=new ImagePanel();
  
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  public ImageViewDialog(){ buildGui(); }
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param p Dialog's parent.
   */
  public ImageViewDialog(Frame p){ super(p); buildGui(); }
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param p Dialog's parent.
   */
  public ImageViewDialog(Dialog p){ super(p); buildGui(); }
  
  // Invoked from constructor.
  private void buildGui()
  {
    setModal(false);
    setTitle("View Dialog");
    
    Container c=getContentPane();
    c.setLayout(new BorderLayout());
    
    add(new JScrollPane(m_panel), BorderLayout.CENTER);
    
    pack();
    setSize(333, 500);
  }
  
  public void show(URL url)
  {
    if (url==null)
    {
      throw new NullPointerException("url");
    }
    
    m_panel.set(url);
    
    setVisible(true);
  }
  
}
